<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2021/11/1
  Time: 16:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>${comicName}</title>
    <script src="${pageContext.request.contextPath}/resources/js/jquery-1.10.1.min.js"></script>
    <style>
        div{
            width: 800px;
            margin: 0 auto;
        }
        .box1{
            text-align: center;
        }
    </style>
</head>
<body>

<div>
    <c:forEach items="${requestScope.chapterImgList}" var="chapterImg">
        <img width="800px" src="http://192.168.2.149:9000/${chapterImg.image}">
    </c:forEach>
</div>

<br>

<div class="box1">
    <a href="${pageContext.request.contextPath}/comics/index">首页</a>
    <c:if test="${requestScope.CurrentChapter>1}">
        <a href="${pageContext.request.contextPath}/comic/${comicName}/chapter/${requestScope.CurrentChapter-1}">上一话</a>
    </c:if>
    <c:if test="${requestScope.CurrentChapter<requestScope.chapterNumber}">
        <a href="${pageContext.request.contextPath}/comic/${comicName}/chapter/${requestScope.CurrentChapter+1}">下一话</a>
    </c:if>
    <a href="${pageContext.request.contextPath}/comic/${comicName}">目录</a>
    <a href="${pageContext.request.contextPath}/chapterComments/comments/${requestScope.chapterImgList[0].chapterId}">评论</a>
</div>

</body>

<script>
    $(function (){
        $.ajax({
            url:"${pageContext.request.contextPath}/comic/${comicName}/chapter/${number}/coin",
            method: "POST",
            success: function (data){
                if(data==='error'){
                    alert("硬币不足")
                    window.location.href="${pageContext.request.contextPath}/comic/${comicName}"
                }
            }
        })
    })
</script>

</html>
